def solution(S: str, T: str) -> int:
    # PLEASE DO NOT MODIFY THE FUNCTION SIGNATURE
    # write code here
    n = len(S)
    m = len(T)
    ans = n
    cnt = 0
    for i in range(min(n, m)):
        cnt += (S[i] != T[i])
        ans = min(ans, cnt + n - 1 - i)
    return ans


if __name__ == '__main__':
    print(solution("aba", "abb") == 1)
    print(solution("abcd", "efg") == 4)
    print(solution("xyz", "xy") == 1)
    print(solution("hello", "helloworld") == 0)
    print(solution("same", "same") == 0)